package com.mingqijia.gassafety.shared.enums;

import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.springframework.util.CollectionUtils;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * @author zhangfei
 * @version 1.0.0
 * @ClassName DealtType.java
 * @Description
 * @createTime 2022年12月01日
 */
@Getter
@RequiredArgsConstructor
public enum DealtType {

    DEALT_TYPE_ARTIFIVAL("人工处理", 1),
    DEALT_TYPE_SMS("短信处理", 2),
    DEALT_TYPE_PHONE("电话处理", 3),
    DEALT_TYPE_TEST("测试", 4),
    OTHER("", 0);

    private final String name;
    private final Integer code;
    public static final String DICT_CODE = "Dealt_type";

    public static DealtType parse(Integer code) {
        List<DealtType> filtered = Arrays.stream(DealtType.values())
                .filter(item -> Objects.equals(item.getCode(), code))
                .collect(Collectors.toList());
        return CollectionUtils.isEmpty(filtered) ? OTHER : filtered.get(0);
    }


}
